import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ScoreRecordVO, ScoreRecordForm, ScoreRecordQuery } from '@/api/member/scoreRecord/types';

/**
 * 查询用户积分记录列表
 * @param query
 * @returns {*}
 */

export const listScoreRecord = (query?: ScoreRecordQuery): AxiosPromise<ScoreRecordVO[]> => {
  return request({
    url: '/member/scoreRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户积分记录详细
 * @param scoreId
 */
export const getScoreRecord = (scoreId: string | number): AxiosPromise<ScoreRecordVO> => {
  return request({
    url: '/member/scoreRecord/' + scoreId,
    method: 'get'
  });
};

/**
 * 新增用户积分记录
 * @param data
 */
export const addScoreRecord = (data: ScoreRecordForm) => {
  return request({
    url: '/member/scoreRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户积分记录
 * @param data
 */
export const updateScoreRecord = (data: ScoreRecordForm) => {
  return request({
    url: '/member/scoreRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户积分记录
 * @param scoreId
 */
export const delScoreRecord = (scoreId: string | number | Array<string | number>) => {
  return request({
    url: '/member/scoreRecord/' + scoreId,
    method: 'delete'
  });
};
